import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/modules/application/smart_warehouse/common_warehouse/common_product_widget.dart';
import 'package:enterprise_v6_app/app/modules/application/smart_warehouse/common_warehouse/warehouse_connection_widget.dart';
import 'package:enterprise_v6_app/app/modules/application/smart_warehouse/product_storage/product_storage_controller.dart';

/// 产品入库页面
class ProductStoragePage extends StatelessWidget {
  ProductStoragePage({super.key});

  final controller = Get.put(ProductStorageController());

  ///获取未开始入库时的样式
  Widget _getUnConnectionView() {
    return CommonWarehouseWidget.getUnConnectionWidget(
      warehouseName: controller.choiceBean?.getShowName(),
      onFirstFunction: () {
        controller.selectWarehouse();
      },
      onSecondFunction: () {
        controller.startExecution();
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
        init: controller,
        builder: (_) {
          return Container(
            alignment: Alignment.topLeft,
            color: const Color(0xffF7F7F7),
            padding: EdgeInsets.only(left: 16.w, right: 16.w, top: 14.w),
            child: controller.isConnection
                ? WarehouseConnectionWidget(
                    type: 0,
                    warehouseName: controller.choiceBean?.getShowName(),
                    warehouseId: controller.choiceBean?.getId(),
                  )
                : _getUnConnectionView(),
          );
        });
  }
}
